home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…tember: Reference Library / Dev.CD Sep 98 RL2.toast / What's New / Software Development Kits / MacOS USB DDK / Examples / KeyboardModule / KeyboardModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-20  |  2.8 KB  |  97 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        KeyboardModule.h
  3.  
  4.     Contains:    Header file for Keyboard Module
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.  
  11. */
  12. #ifndef __KeyboardModuleH__
  13. #define __KeyboardModuleH__
  14.  
  15. #include <Types.h>
  16. #include <Devices.h>
  17. #include <DriverServices.h>
  18. #include <Processes.h>
  19. #include <USB.h>
  20.  
  21. void     PostUSBKeyToMac(UInt16 rawUSBkey);
  22. void    PostADBKeyToMac(UInt16 virtualKeycode, UInt8 state);
  23.  
  24. void    USBDemoKeyIn(UInt32 refcon, void * theData);
  25. void    InitUSBKeyboard(void);
  26. void     KBDHIDNotification(UInt32 devicetype, UInt8 NewHIDData[], UInt8 OldHIDData[]);
  27.  
  28. Boolean    SetBit(UInt8 *bitmapArray, UInt16 index, Boolean value);
  29.  
  30. static     OSStatus    KeyboardModuleInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  31. static     OSStatus    KeyboardInterfaceInitialize(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
  32. static     OSStatus    KeyboardModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc);
  33.  
  34. void    KeyboardModuleInitiateTransaction(USBPB *pb);
  35. void    KeyboardModuleDelay1CompletionProc(USBPB *pb);
  36. void    KeyboardCompletionProc(USBPB *pb);
  37. void    InterfaceEntry(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterfaceDescriptor, USBDeviceDescriptorPtr pDeviceDescriptor, USBDeviceRef device);
  38.  
  39. OSErr     FindHIDInterfaceByNumber(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc);
  40. void     NotifyRegisteredHIDUser(UInt32 devicetype, UInt8 hidReport[]);
  41.  
  42. #define kKeyboardRetryCount        3
  43. #define kKeyboardModifierBits    8
  44. #define kKeyboardReportKeys        6
  45. #define    kKeyboardOffsetToKeys    2
  46. #define kKeyboardReportSize        8
  47.  
  48. enum driverstages
  49. {
  50.     kUndefined = 0,
  51.     kSetKeyboardLEDs,
  52.     kGetFullConfiguration,
  53.     kFindInterfaceAndSetProtocol,
  54.     kSetIdleRequest,
  55.     kFindAndOpenInterruptPipe,
  56.     kReadInterruptPipe,
  57.     kReturnFromDriver =     0x1000,
  58.     kRetryTransaction =     0x2000,
  59.     kSyncTransaction =         0x4000,
  60.     kCompletionPending =     0x8000
  61. };
  62.  
  63. typedef struct
  64. {
  65.     USBPB                             pb;
  66.     void (*handler)(USBPB             *pb);
  67.  
  68.     USBDeviceRef                    deviceRef;
  69.     USBInterfaceRef                    interfaceRef;
  70.     USBPipeRef                        pipeRef;
  71.     
  72.     USBDeviceDescriptor             deviceDescriptor;
  73.     USBInterfaceDescriptor            interfaceDescriptor;
  74.  
  75.     USBConfigurationDescriptorPtr     pFullConfigDescriptor;
  76.     USBInterfaceDescriptorPtr        pInterfaceDescriptor;
  77.     USBEndPointDescriptorPtr        pEndpointDescriptor;
  78.     
  79.     UInt32                            hidDeviceType;
  80.     UInt8                            hidReport[8];
  81.     UInt8                            oldHIDReport[8];
  82.     UInt8                            padding[8];
  83.     
  84.     Boolean                            sendRawReportFlag;
  85.     Boolean                            hidEmulationInit;
  86.     
  87.     HIDInterruptProcPtr             pSHIMInterruptRoutine;
  88.     HIDInterruptProcPtr             pSavedInterruptRoutine;
  89.     
  90.     UInt32                            interruptRefcon;
  91.     
  92.     SInt32                             retryCount;
  93.     SInt32                            delayLevel;
  94.     SInt32                            transDepth;
  95. } usbKeyboardPBStruct;
  96.  
  97. #endif //__KeyboardModuleH__